package io.yuncheng.modules.sys.service.impl;

import io.yuncheng.common.config.SpringBootBeanAutowiringSupport;
import io.yuncheng.common.utils.XmlUtil;
import io.yuncheng.modules.sys.entity.xml.XmlOrgEntity;
import io.yuncheng.modules.sys.entity.xml.XmlTaskEntity;
import io.yuncheng.modules.sys.entity.xml.XmlUserEntity;
import io.yuncheng.modules.sys.service.IXfireService;
import io.yuncheng.modules.sys.service.SysDeptService;
import io.yuncheng.modules.sys.service.SysUserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.codehaus.xfire.jaxws.binding.SOAPBinding;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.jws.WebService;
import javax.xml.ws.BindingType;
/*
 * Xfire 接口类实现
 * @author tan
 * @data 2021-11-12
 */
/*
 * serviceName:?wsdl前缀
 * targetNamespace:命名空间
 * name:无实际意义
 */

/**
 *接口全路径地址
 *
 */
@WebService(serviceName = "orderService", // 与接口中指定的name一致
            endpointInterface = "io.yuncheng.modules.sys.service.IXfireService"// 接口地址
)
@BindingType(value = SOAPBinding.SOAP12HTTP_BINDING)
@Component("xfireServiceImpl")
@Slf4j
public class XfireServiceImpl extends SpringBootBeanAutowiringSupport implements IXfireService {
    @Resource
    private SysUserService sysUserService;

    @Resource
    private SysDeptService sysDeptService;

    @Override
    public int CA_UpdateForSame(String xmlString, String strTrustId) {
        log.info("----xmlString 数据 xmlString {}   strTrustId : {} " , xmlString , strTrustId);
        XmlTaskEntity xmlTaskEntity = XmlUtil.xmlParseEntity(xmlString);
        XmlOrgEntity org = xmlTaskEntity.getOrg();
        if(org != null){
            return sysDeptService.changeDeptByServiceTask(org);
        }
        XmlUserEntity user = xmlTaskEntity.getUser();
        if(user != null){
            return sysUserService.changeUserByServiceTask(user);
        }
        return 1;
    }

    public static void main(String[] args) {

    }
}


